package cn.ai.shoes.client.utils;

import cn.ai.shoes.client.entity.Shoe;
import cn.ai.shoes.client.entity.interFace.LoreNameProvider;

import cn.ai.shoes.common.constant.ShoeConstants;
import cn.ai.shoes.common.exception.ServiceException;
import cn.ai.shoes.common.exception.constant.GlobalErrorCodeConstants;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import org.jetbrains.annotations.NotNull;

public class ComfyuiSmallUtils {
    @NotNull
    public static <T extends LoreNameProvider> String getLoreName(T vo) {
        String loreName =null;
        try {
            Shoe shoe = ShoeConstants.SHOE_MAP.get(vo.getLoreName());
            if (shoe == null) {
                shoe =new Shoe("元素", "element");
            }
            loreName = shoe.getName();
        }
        catch (Exception e){
            throw new ServiceException(GlobalErrorCodeConstants.SHOE_NOT_EXIST);
        }
        if (StringUtils.isEmpty(loreName)) {
            throw new ServiceException(GlobalErrorCodeConstants.SHOE_NOT_EXIST);
        }
        return "鞋子Lora/" + loreName+ ".safetensors";
    }

}
